<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text" id="t1">
    <select name="" id="s1">
        <option value="o1">+</option>
        <option value="o2">-</option>
        <option value="o3">*</option>
        <option value="o4">/</option>
    </select>
    <input type="text" id="t2">
    <input type="button" value="计算" id="but1">
    <input type="text" id="t3">
</body>
    <script>
        function a(){
            var t11=document.getElementById('t1').value;
            var t22=document.getElementById('t2').value;
            var a1=parseInt(t11)+parseInt(t22);
            document.getElementById('t3').value=a1;
        }
        function b(){
            var t11=document.getElementById('t1').value;
            var t22=document.getElementById('t2').value;
            var a1=parseInt(t11)-parseInt(t22);
            document.getElementById('t3').value=a1;
        }
        function c(){
            var t11=document.getElementById('t1').value;
            var t22=document.getElementById('t2').value;
            var a1=parseInt(t11)*parseInt(t22);
            document.getElementById('t3').value=a1;
        }
        function d(){
            var t11=document.getElementById('t1').value;
            var t22=document.getElementById('t2').value;
            var a1=parseInt(t11)/parseInt(t22);
            document.getElementById('t3').value=a1;
        }
        function abcd(){
            //拿到s11对象
            var s11=document.getElementById('s1');
            //console.log(s11);
            //拿到选中项的索引
            var index=s11.selectedIndex;  
            //拿到选中项options的value
            var s111=s11.options[index].value;
            //console.log(s111);

            switch (s111){
                case 'o1':
                    a()
                    console.log('+');
                    break;
                case 'o2':
                    b()
                    console.log('-');
                    break;
                case 'o3':
                    c()
                    console.log('*');
                    break;
                case 'o4':
                    d()
                    console.log('/');
                    break;
                default:
                    break;
            }
        }
        document.getElementById('but1').onclick=abcd;

    </script>
</html>